package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-03-14
 * Time: 21:55
 */
public class Test {
    public static void main(String[] args) {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Triangle triangle = new Triangle();
        String[] strings = {"cycle", "cycle","rect", "rect","triangle","triangle"};
        for(String s : strings){
            if(s.equals("cycle")){
                cycle.draw();
            }else if(s.equals("rect")){
                rect.draw();
            }else{
                triangle.draw();
            }
        }
    }
    public static void main2(String[] args) {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Triangle triangle = new Triangle();
        Shape[] shapes = {cycle,cycle,rect,rect,triangle,triangle};

        for(Shape shape : shapes){
            shape.draw();
        }
        /*for (int i = 0; i < shapes.length; i++) {
            shapes[i].draw();
        }*/
    }
    public static void drawMap(Shape shape){
        shape.draw();
    }
    public static void main1(String[] args) {
        Rect rect = new Rect();
        Cycle cycle = new Cycle();
        Triangle triangle = new Triangle();
        drawMap(rect);
        drawMap(cycle);
        drawMap(triangle);
    }
}
